/*
 * SystemClient_StubImpl.java
 *
 * Created on October 10, 2006, 8:27 PM
 */

package com.asaga.tools;

import java.beans.*;
import java.io.Serializable;
import java.util.Date;
import java.util.ArrayList;

/**
 * @author checkout
 */
public class SystemClient_StubImpl extends Object implements SystemClient {
    private String fname;
    private int id;
    private String state;
    private String city;
    private String addr1;
    private String addr2;
    private String lname;
    private String zip;
    private String phone;
    private String cell;
    private String email;
    private String password;
    private String status;
    private String validation;
    private Date regDate;
    private Date lastVisit;
    private String welcomeMsg = "";
    ArrayList userList;
    User tempUser;
    private int permissionId;
    private int groupId;
    private int eventId;
    private int classId;
    
    
    
    public SystemClient_StubImpl() {
        id = 2;
        userList = new ArrayList();
        userList.add(new User(1, "Mike", "Mixon", "mmixon@uga.edu", "mike"));
        userList.add(new User(2, "Scott", "Bales", "gisman@bellsouth.net", "scott"));
        userList.add(new User(3, "Rhonda", "Gantt", "rgantt@uga.edu", "rhonda"));
        userList.add(new User(4, "Jeremy", "Sanderlin", "sanderj@uga.edu", "jeremy"));
    }
    
    public void setId(int i){
        id = i;
    }
    
    public int getId(){
        return id;
    }

    public void setFname(String f) {
        fname = f;
    }

    public String getFname() {
        return fname;
    }

    public void setLname(String l) {
        lname = l;
    }

    public String getLname() {
        return lname;
    }

    public void setAddr1(String a1) {
        addr1 = a1;
    }

    public String getAddr1() {
        return addr1;
    }

    public void setAddr2(String a2) {
        addr2 = a2;
    }

    public String getAddr2() {
        return addr2;
    }

    public void setCity(String c) {
        city = c;
    }

    public String getCity() {
        return city;
    }

    public void setState(String s) {
        state = s;
    }

    public String getState() {
        return state;
    }

    public String getZip() {
        return zip;
    }

    public void setZip(String zip) {
        this.zip = zip;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getCell() {
        return cell;
    }

    public void setCell(String cell) {
        this.cell = cell;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getValidation() {
        return validation;
    }

    public void setValidation(String validation) {
        this.validation = validation;
    }

    public Date getRegDate() {
        return regDate;
    }

    public void setRegDate(Date regDate) {
        this.regDate = regDate;
    }

    public Date getLastVisit() {
        return lastVisit;
    }

    public void setLastVisit(Date lastVisit) {
        this.lastVisit = lastVisit;
    }

    public void addUser() {
        int theID = userList.size();
        theID = theID +1;
        userList.add(new User(theID, fname, lname, email, password));
        id = theID;
        
    }

    public void updateUser(int userID) {
        tempUser = (User)userList.get(userID+1);
        tempUser.fname = fname;
        tempUser.lname = lname;
        tempUser.password = password;
        tempUser.email = email;
    }

    public void login(String email, String password){
        validation = "no";
        for(int i = 0; i < userList.size(); i++){
            tempUser = (User)userList.get(i);
            if(tempUser.email == email){
                if(tempUser.password == password){
                    validation = "yes";
                    break;
                }
                else
                    validation = "no";
            }
        }
        if(validation.equals("yes")){
            id = tempUser.userID;
            email = tempUser.email;
            fname = tempUser.fname;
            lname = tempUser.lname;
            password = tempUser.password;
        }
    }
    
    private class User {
        public int userID;
        public String fname;
        public String lname;
        public String email;
        public String password;
        public User(int id, String f, String l, String e, String p){
            userID = id;
            fname = f;
            lname = l;
            email = e;
            password = p;
        }
    }
    
}
